﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OpenFlashChart;

namespace V5_EShop.Admin.Product {
    /// <summary>
    /// Admin_ProductOrderChart 的摘要说明
    /// </summary>
    public class Admin_ProductOrderChart : IHttpHandler {

        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/plain";
            OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
            chart.Title = new Title("订单报表详细");

            BarGlass bar = new OpenFlashChart.BarGlass();
            Random random = new Random();
            bar.Colour = "#345";

            bar.FillAlpha = 0.4;
            bar.Text = "数量";

            bar.FontSize = 10;
            List<BarGlassValue> values = new List<BarGlassValue>();
            for (int i = 0; i < 11; i++) {

                values.Add(new BarGlassValue(random.Next(i, i * 2)));
            }
            BarGlassValue barGlassValue = new BarGlassValue(4);
            barGlassValue.Tip = "#bottom#:top#top#<br>#val#";
            barGlassValue.Color = "#eee";
            values.Add(barGlassValue);
            bar.Values = values;
            chart.AddElement(bar);
            YAxis yaxis = new YAxis();
            yaxis.Steps = 4;
            yaxis.SetRange(0, 20);
            chart.Y_Axis = yaxis;
            chart.Y_Axis.SetRange(0, 24, 3);
            chart.Tooltip = new ToolTip("提示:#val#");
            string s = chart.ToPrettyString();

            context.Response.Clear();
            context.Response.CacheControl = "no-cache";
            context.Response.Write(chart.ToPrettyString());
            context.Response.End();
        }

        public bool IsReusable {
            get {
                return false;
            }
        }
    }
}